package day4;

import java.util.Scanner;

public class te11 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int [][]arr = new int[n][m];
        int count=1,time=0;
        for(;;){
            for(int k = 0 ; k < m-2*time ;  k++){
                arr[time][time+k]=count;
                count++;
            }
            if(count == n*m+1) break;
            for(int k=1; k<n-2*time ;k++){
                arr[k+time][m-1-time] = count;
                count++;
            }
            if(count == n*m+1) break;
            for(int k=1; k<n-2*time ;k++){
                arr[k+time][time]=count;
                count++;
            }
            if(count == n*m+1) break;
            for(int k=1; k<m-1-2*time ;k++){
                arr[n-1-time][k+time]=count;
                count++;
            }
            if(count == n*m+1) break;
            time++;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                System.out.print(arr[i][j]+"\t");
            }
            System.out.println(" ");
        }
    }
}
